package cu.tedu._05weibo.config;

import cu.tedu._05weibo.interptors.MyInterceptor1;
import cu.tedu._05weibo.interptors.UserLoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MvcConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(new MyInterceptor1());
//        registry.addInterceptor(new MyInterceptor1()).addPathPatterns("/v1/weibo/**");
//        registry.addInterceptor(new MyInterceptor1()).addPathPatterns("/v1/comment/**").excludePathPatterns("/v1/comment/selectByWeiboId");

        //注册拦截器
        registry.addInterceptor(new UserLoginInterceptor())
                .addPathPatterns("/v1/weibo/insert", "/v1/comment/insert");
    }
}
